layui.use(['form', 'layer', 'table', 'laytpl'], function () {
	var layer = top.layui.layer,
		$ = layui.jquery,
		table = layui.table;

	window.active = {
		reload: () => {
			table.reload("tableListTable");
		},
		edit: (data) => {
			popEdit(data, 'page/robot/addintegral.html', ["400px", "250px"]);
		},
		addPoints:  (data, obj) => {
			layer.prompt({
				value: data.score,
				title: '修改积分',
			}, async (value, index, elem) => {
				layer.close(index);

				var money_id=data.money_id
				   score=value
				await ajaxAsync('moneySet/score', {money_id,score}, 'POST')
				obj.update(data);
				active.reload()
			});
		},
		addLT: (data, obj) => {
			layer.prompt({
				value: data.money,
				title: '修改金额',
			}, async (value, index, elem) => {
				layer.close(index);

				var money_id=data.money_id
					money=value
				await ajaxAsync('moneySet/money', {money_id,money}, 'POST')
				obj.update(data);
				active.reload()
			});
		},
		del: (data) => {
			// money_id = data.money_id
			popDelete(data.name, 'moneySet', {
				money_id: data.money_id
			});
		}
	}

	//表格外按钮操作
	$('.tableHead .layui-btn').on('click', function () {
		var type = $(this).data('type');
		active[type] ? active[type].call(this) : '';
	});
	//表格按钮操作
	table.on('tool(tableList)', function (obj) {
		var type = obj.event;
		active[type] ? active[type].call(this, obj.data, obj) : '';
	});

})